@include('admin.layout.css')
@include('admin.layout.js')




<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">





    <div class="layui-form-item">
        <label class="layui-form-label">任务视频</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="test2">上传视频</button>
            <input type="hidden" name="task_data" id="img_url1">
            <div class="layui-upload-list" >
                <a href="" id="img_url_show1" target="_blank">查看视频</a>

                <p id="demoText"></p>
            </div>
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">任务名称</label>
        <div class="layui-input-block">
            <input type="text"  name="task_title"  placeholder="请输入任务名称" autocomplete="off" class="layui-input" >
        </div>
    </div>






    <div class="layui-form-item">
        <label class="layui-form-label">任务奖励</label>
        <div class="layui-input-block">
            <input type="text"  name="task_num"  placeholder="请输入任务奖励" autocomplete="off" class="layui-input" >
        </div>
    </div>




    <div class="layui-form-item">
        <label class="layui-form-label">任务说明文字</label>
        <div class="layui-input-block">
            <textarea name="task_content" rows="10" cols="30"></textarea>
        </div>
    </div>







    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="submit" id="submit" value="确认">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="取消">
    </div>

</div>


<script>

    UI.upload('#test1',function (res) {
        if (res.code !== 200) {
            Utils.errorToast(res.msg);
        }else{
            Utils.successToast('上传成功');
            $('#img_url_show').attr('src',res['data']['src']);
            $('#img_url').val(res['data']['src']);
        }
    });

    UI.upload('#test2',function (res) {
        if (res.code !== 200) {
            Utils.errorToast(res.msg);
        }else{
            Utils.successToast('上传成功');
            $('#img_url_show1').attr('href',res['data']['src']);
            $('#img_url1').val(res['data']['src']);
        }
    });

    UI.upload('#test3',function (res) {
        if (res.code !== 200) {
            Utils.errorToast(res.msg);
        }else{
            Utils.successToast('上传成功');
            $('#img_url_show3').attr('src',res['data']['src']);
            $('#img_url3').val(res['data']['src']);
        }
    });

    layui.use(['laydate','form'], function() {
        let form = layui.form;
        form.on('submit(submit)', function(data){

            Api.add("{{route('admin.task.add')}}",data.field,function(res){
                if (res.code !== 200){
                    Utils.errorToast(res.msg);
                    return;
                }
            });
        });


    });
</script>
